import React from 'react';
import {
  View,
  TouchableOpacity,
  Text,
  ScrollView,
  Image
} from 'react-native';

import BasePage from '../common/BasePage';
import CommonStyles from '../../common/CommonStyles';
import Config from '../../config';
import SizeUtils from '../../common/SizeUtils';
import Constants from '../../common/Constants';
import ToastUtils from '../../common/ToastUtils';

import HeartBaseContentPage from '../../pages/heart/HeartBaseContentPage';

var worry_config=[{icon:require("../../../resource/images/heart/love_thing_icon1.png"), width:48, height:48,title:"倾诉空间"},
{icon:require("../../../resource/images/heart/love_thing_icon1.png"), width:48, height:48,title:"秘密留言"},
{icon:require("../../../resource/images/heart/love_thing_icon1.png"), width:48, height:48,title:"预约咨询"}]

var test_worry_data=[{image:require('../../../resource/images/heart/temp/1.png'),name:"张和平",title:"外聘专家",seeCount:12381},
{image:require('../../../resource/images/heart/temp/2.png'),name:"张和平",title:"外聘专家",seeCount:121}]
export default class HeartWorryPage extends HeartBaseContentPage {
  constructor(props) {
    super(props);
  }


  //override
  _renderTab(){
    return (<View style = {{flexDirection: 'row', justifyContent: 'space-around',
      width:SizeUtils.getWindowSize().width,
        marginTop:SizeUtils.translateDesignNumToCode(50)}}>
                {this._getTabButton(worry_config[0], 0)}
                 {this._getTabButton(worry_config[1], 1)}
                  {this._getTabButton(worry_config[2], 2)}
        </View>);
  }

  _renderContent(){
    return <View style={{width:SizeUtils.getWindowSize().width,flexDirection: 'column',alignItems: 'center',
              marginTop:SizeUtils.translateDesignHeightToCode(50)}}>
           <View style={{width:SizeUtils.getWindowSize().width-SizeUtils.translateDesignWidthToCode(80),flexDirection: 'column',alignItems: 'center',}}>
               <View style={{position:"absolute",left:0,bottom:SizeUtils.translateDesignHeightToCode(16),
               backgroundColor:"#eeeeee",width:SizeUtils.getWindowSize().width-SizeUtils.translateDesignWidthToCode(80),
               height:SizeUtils.translateDesignNumToCode(3)}}>
               </View>
               <Text style={{paddingLeft:SizeUtils.translateDesignWidthToCode(20),
                color: "#000",fontWeight:'bold', backgroundColor:"#ffffff",
                paddingRight:SizeUtils.translateDesignWidthToCode(20),
                textAlign:"center", fontSize:SizeUtils.translateFontSizeToCode(32)}}>推荐专家
               </Text>

             </View>
           {this._renderContentItem(0)}
           {this._renderContentItem(1)}
       </View>
  }

  _renderContentItem(index){
    var item = test_worry_data[index];
    var itemWidth =SizeUtils.getWindowSize().width-SizeUtils.translateDesignWidthToCode(80);
    return (
      <TouchableOpacity style={{width:itemWidth,
              borderBottomWidth:SizeUtils.translateDesignNumToCode(3), borderColor:"#eeeeee",
           marginTop:SizeUtils.translateDesignHeightToCode(30),paddingBottom:SizeUtils.translateDesignHeightToCode(23),}}
              onPress={() =>this._onPressContentItem(index)}>
            <Image source={item.image} style={{width:itemWidth,height:SizeUtils.translateDesignWidthToCode(315)}}/>
            <View style={{marginTop:SizeUtils.translateDesignHeightToCode(26),width:itemWidth,flexDirection:"row", justifyContent:"space-between"}}>
               <Text style={{ marginLeft:SizeUtils.translateDesignWidthToCode(10),color: "#000",fontWeight:'bold',
               fontSize:SizeUtils.translateFontSizeToCode(26)}}>{item.name}<Text style={{color: "#999",
                fontSize:SizeUtils.translateFontSizeToCode(26)}}>{item.title}</Text>
              </Text>
              <Text style={{color: "#999",
              textAlign:"right",fontWeight:'normal',fontSize:SizeUtils.translateFontSizeToCode(26)}}>{item.seeCount}个人咨询过</Text>
            </View>
        </TouchableOpacity>)
  }

  _getBackImage(){
    return require("../../../resource/images/heart/love_thing_icon1.png");
  }

  _onPressContentItem(index) {
    let url = "";
    if(index == 0) {
      url = "http://daqing.womob.cn/app/index.php?i=4&c=entry&id=16&do=member&m=oilfield_team";
    }
    else if(index == 1) {
      url = "http://daqing.womob.cn/app/index.php?i=4&c=entry&id=17&do=member&m=oilfield_team";
    }
    this.gotoPage(Config.pages.heart_common_web, {url:url});
  }

 _onPressPageBtn(index) {
    console.log("_onPressItem"+index);
    let url = "";
    if(index == 0) {
      url = "http://daqing.womob.cn/app/index.php?i=4&c=entry&do=advisory&m=oilfield_eap";
    }
    else if(index == 1) {
      url = "http://daqing.womob.cn/app/index.php?i=4&c=entry&do=leavemessage&m=oilfield_eap";
    }
    else if(index == 2) {
      ToastUtils.show("功能暂未开放");
      return;
    }
    this.gotoPage(Config.pages.heart_common_web, {url:url});
  }
}
